<?php

namespace app\shop\model;

class Sn extends \ShopModel
{
    protected $table = 'sh_sn';

    protected $pk = 'sn_id';
    protected $autoWriteTimestamp = true;
    protected $updateTime = false;

    public function getSn($action,$count){
        $thisData = $this->where('sn_action',$action)->find();

        $thisnumber = $thisData['sn_number'];

            $retData = [];
            for ($i=0;$i<$count;$i++){
                $thisnumber=$thisnumber+1;
                $retData[$i] = $thisData['sn_letter'] . $thisnumber;
                if($i==($count-1)){
                    $thisData = $this->where('sn_action',$action)->update(['sn_number'=>$thisnumber]);
                }
            }


        return $retData;
    }


}